import {createApp} from 'vue'
import App from './App.vue'
import router from './router'
import '@/style.css'
import {createPinia} from 'pinia'
import AppHeader from '@/components/AppHeader.vue'
import {startPlcService} from '@/services/plc_service'
import {startMesEventListen} from '@/services/mes_integration'
import {startChartDataService} from '@/services/chart-data-service'
import {getConfig} from '@/mapper/config-store'
import plcAddressStore from '@/api/plcAddress';

const app = createApp(App)
const pinia = createPinia()

// 添加路由初始化日志
router.isReady().then(() => {
    // console.log('路由初始化完成');
    // console.log('当前路由:', router.currentRoute.value);
})

// 全局路由错误处理
router.onError((error) => {
    console.error('路由错误:', error)
})

// 全局注册 AppHeader 组件
app.component('AppHeader', AppHeader)

app.use(pinia)
app.use(router)
app.mount('#app')
//启动plc服务
try {
    //初始化plc地址
    // plcAddressStore.initDefaultValue();
    // //启动plc监听服务
    // startPlcService()
    // //启动mes事件监听
    // startMesEventListen()
    // //启动图表数据服务
    // startChartDataService()
} catch (e) {
    console.log(e)
}
